package com.google.code.jgib.util.growl;

import com.google.code.jgib.growl.requests.GntpNotificationRequest.NotificationType;

public class GntpUtil {
	
	
	private static String newLine = "\r\n";

	public static String createRegisterRequest() {
		String result = "";
		
		result += gFT("REGISTER NONE");
		result += gFT("Application-Name: jgib");
		result += gFT("Notifications-Count: 5");
		result += gFT("");
		
		result += gFT("Notification-Name: Message Recieved");
		result += gFT("Notification-Enabled: True");
		result += gFT("");
		
		result += gFT("Notification-Name: User Join");
		result += gFT("Notification-Enabled: True");
		result += gFT("");
		
		result += gFT("Notification-Name: User Part");
		result += gFT("Notification-Enabled: True");
		result += gFT("");
		
		result += gFT("Notification-Name: Disconnected");
		result += gFT("Notification-Enabled: True");
		result += gFT("");
		
		result += gFT("Notification-Name: Connected");
		result += gFT("Notification-Enabled: True");

		result+= gFT("");
		result+= gFT("");
		
		return result;
	}
	
	
	public static String createNotificationRequest(NotificationType type, String msg) {
		String result = "";
		result += gFT("NOTIFY NONE");
		result += gFT("Application-Name: jgib");
		
		switch(type){
		
		case CONNECT:
			result += gFT("Notification-Name: Connected");
			result += gFT("Notification-Title: Connected");
			break;		
		case DISCONNECT:
			result += gFT("Notification-Name: Disconnected");
			result += gFT("Notification-Title: Disconnected");
			result += gFT("Notification-Sticky: True");
			break;		
		case NEWMSG:
			result += gFT("Notification-Name: Message Recieved");
			result += gFT("Notification-Title: Message Recieved");
			break;		
		case USERJOIN:
			result += gFT("Notification-Name: User Join");
			result += gFT("Notification-Title: User Join");
			break;		
		case USERPART:
			result += gFT("Notification-Name: User Part");
			result += gFT("Notification-Title: User Part");
			break;
		
		}
		result += gFT("Notification-Text: "+msg);

		result+= gFT("");
		result+= gFT("");
		
		return result;
	}	
	
	
/**
 * gets text followed by newLine
 * @param string
 * @return
 */
	private static String gFT(String string) {
		return string+newLine;
	}

}
